//
//  VCOfAddContact.m
//  UI_08_homework_UITableView
//
//  Created by li cheng on 16/7/25.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "VCOfAddContact.h"
#import "LabelAndTextFiled.h"

@interface VCOfAddContact ()
@property (nonatomic, strong) LabelAndTextFiled *phoneNumber;
@property (nonatomic, strong) LabelAndTextFiled *name;
@property (nonatomic, strong) LabelAndTextFiled *gender;
@property (nonatomic, strong) LabelAndTextFiled *age;
@end

@implementation VCOfAddContact

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    self.phoneNumber = [[LabelAndTextFiled alloc] initWith:CGRectMake(20, 20, 300, 60) labelScale:2 textFiled:3 labeName:@"电话号码" textFieldPlaceholder:@"请输入电话号码"];
    [self.view addSubview:self.phoneNumber];
    self.name = [[LabelAndTextFiled alloc] initWith:CGRectMake(20, 120, 300, 60) labelScale:2 textFiled:3 labeName:@"姓名" textFieldPlaceholder:@"请输入姓名"];
    [self.view addSubview:self.name];
    self.gender = [[LabelAndTextFiled alloc] initWith:CGRectMake(20, 220, 300, 60) labelScale:2 textFiled:3 labeName:@"性别" textFieldPlaceholder:@"请输入性别"];
    [self.view addSubview:self.gender];
    self.age = [[LabelAndTextFiled alloc] initWith:CGRectMake(20, 320, 300, 60) labelScale:2 textFiled:3 labeName:@"年龄" textFieldPlaceholder:@"请输入年龄"];
    [self.view addSubview:self.age];
    // 保存按钮
    UIButton *buttonOfKeep = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfKeep.frame = CGRectMake(self.view.bounds.size.width / 2 - 60, 450, 120, 60);
    buttonOfKeep.backgroundColor = [UIColor yellowColor];
    [buttonOfKeep setTitle:@"保存" forState:UIControlStateNormal];
    [buttonOfKeep addTarget:self action:@selector(keepAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttonOfKeep];

}
- (void)keepAction:(UIButton *)button{
    self.dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:self.phoneNumber.textField.text, @"phoneNumebr", self.name.textField.text, @"name", self.gender.textField.text, @"gender", self.age.textField.text, @"age", nil];
    if (self.vcOfAddContactDelegate && [self.vcOfAddContactDelegate respondsToSelector:@selector(addContact:)]) {
        [self.vcOfAddContactDelegate addContact:_dic];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
